<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello React!</title>
<!-- <script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
<script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
<script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script> -->
<script src="./react.development.js"></script>
<script src="./react-dom.development.js"></script>
<script src="./babel.min.js"></script>
<script src="./prop-types.js"></script>
</head>
<body>
<div id="example"></div>
<div id="example1"></div>
<div id="example2"></div>
<div id="example3"></div>
<script type="text/babel">
class App extends React.Component{
  constructor(props){
    super(props);
    console.log(this);
    //modify this
    this.handleClick = this.handleClick.bind(this);
  }
  test(){
    console.log(this)//没有this
  }
  // test1 = ()=>{//脚手架里面支持
  //   console.log(this)
  // }
  handleClick(){
    console.log(this.refs.ipt0.value)
  }
  handleBlur(event){
    console.log(event.target.value)
  }
  mapBlur(str){
    console.log(str)
  }
  render(){
    let {arr} = this.props;
    return (
      <div>
        <input type="text" ref="ipt0" onFocus={this.test} onBlur={this.handleBlur}/>
        <button onClick={this.handleClick}>点击显示数据</button>
        {
          arr.map((v,i)=>{//通过标签传递事件并不成功
            return <Welcome title={v} blur={this.mapBlur} index={i} key={i}/>
          })
        }
      </div>
    )
  }
}
function Welcome(props){
  console.log(props)
  function blur(e){
    props.blur(e.target.value)
  }
  return (
    <h2>
      <span>{props.title}</span>
      <input type="text" onBlur={blur} />
    </h2>
  )
}
let inputList = ['时间','地点','人物'];
ReactDOM.render(<App arr={inputList} />,document.getElementById('example'))
</script>
</body>
</html>